<!-- 本期盈亏-->
<template>
	<div>
		<div class="bill-title contentBox mt30">
			本期盈亏：
			<span>
				{{ handleTotalNumber('USDT', netAmount, 2, true, true) }}
			</span>
		</div>
		<!-- 本期盈亏 -->
		<el-table
			key="本期盈亏"
			v-loading="loading"
			element-loading-spinner="el-icon-loading"
			size="mini"
			class="small-size-table"
			:data="[data]"
			border
			style="width: 100%; margin: 15px 0"
			:header-cell-style="getRowClass"
			highlight-current-row
		>
			<el-table-column align="center">
				<template slot-scope="scope">德州场馆</template>
			</el-table-column>
			<el-table-column
				prop="dxClubNetAmount"
				align="center"
				label="俱乐部游戏输赢"
			>
				<template slot="header" slot-scope="{ column, $index }">
					<span>俱乐部游戏输赢</span>
				</template>
				<template slot-scope="scope">
					<FormItem :scope="scope" :updateData="updateData" />
				</template>
			</el-table-column>
			<el-table-column
				prop="dxSquidNetAmount"
				align="center"
				label="鱿鱼游戏输赢"
			>
				<template slot="header" slot-scope="{ column, $index }">
					<span>鱿鱼游戏输赢</span>
				</template>
				<template slot-scope="scope">
					<FormItem :scope="scope" :updateData="updateData" />
				</template>
			</el-table-column>
			<el-table-column
				prop="serviceChargeRoundAmount"
				align="center"
				label="局服务费"
			>
				<template slot="header" slot-scope="{ column, $index }">
					<span>
						局服务费
						<el-tooltip
							class="item"
							effect="dark"
							content="会员被收取的局服务费之和"
							placement="top-start"
						>
							<i class="el-icon-question"></i>
						</el-tooltip>
					</span>
				</template>
				<template slot-scope="scope">
					<FormItem :scope="scope" :updateData="updateData" />
				</template>
			</el-table-column>
			<el-table-column
				prop="dxInsureNetAmount"
				align="center"
				label="保险投注输赢"
			>
				<template slot="header" slot-scope="{ column, $index }">
					<span>保险投注输赢</span>
				</template>
				<template slot-scope="scope">
					<FormItem :scope="scope" :updateData="updateData" />
				</template>
			</el-table-column>
			<el-table-column
				prop="valueAddedTotalAmount"
				align="center"
				label="增值服务消费"
			>
				<template slot="header" slot-scope="{ column, $index }">
					<span>
						会员增值服务消费
						<el-tooltip
							增值服务消费="item"
							effect="dark"
							content="会员在德州场馆内因增值服务、商城、返利等功能引起的资金变动。"
							placement="top-start"
						>
							<i class="el-icon-question"></i>
						</el-tooltip>
					</span>
				</template>
				<template slot-scope="scope">
					<FormItem :scope="scope" :updateData="updateData" />
				</template>
			</el-table-column>
			<el-table-column
				prop="rebateAmount"
				align="center"
				label="返水金额"
			>
				<template slot="header">
					<span>
						返水金额
						<el-tooltip
							class="item"
							effect="dark"
							content="统计当期获得的返水金额; 公式：服务费贡献*返水比例；公式仅作参考测算，测算结果不等同实际发放金额"
							placement="top"
						>
							<i class="el-icon-question"></i>
						</el-tooltip>
					</span>
				</template>
				<template slot-scope="scope">
					<FormItem :scope="scope" :updateData="updateData" />
				</template>
			</el-table-column>
			<el-table-column
				prop="dxMemberNetAmount"
				align="center"
				label="会员盈亏"
			>
				<template slot="header">
					<span>
						会员盈亏
						<el-tooltip
							class="item"
							effect="dark"
							content="汇总德州场馆盈亏的总额; 公式：俱乐部游戏输赢+鱿鱼游戏输赢+局服务费+保险投注输赢+增值服务消费+返水金额"
							placement="top"
						>
							<i class="el-icon-question"></i>
						</el-tooltip>
					</span>
				</template>
				<template slot-scope="scope">
					{{ aomunt(dxClubMemberNetAmount) }}
				</template>
			</el-table-column>
		</el-table>
		<!-- 本期盈亏 end -->

		<!-- 德州俱乐部俱乐部服务费贡献 -->
		<el-table
			key="德州俱乐部俱乐部服务费贡献"
			border
			v-loading="loading"
			element-loading-spinner="el-icon-loading"
			size="mini"
			class="small-size-table"
			:data="[data]"
			style="width: 100%; margin: 15px 0"
			:header-cell-style="getRowClass"
			highlight-current-row
		>
			<el-table-column align="center">
				<template slot-scope="scope">德州场馆</template>
			</el-table-column>
			<el-table-column
				prop="serviceChargeContributionAmount"
				align="center"
				label="俱乐部服务费贡献"
			>
				<template slot-scope="scope">
					<FormItem :scope="scope" :updateData="updateData" />
				</template>
			</el-table-column>
			<el-table-column
				prop="dxInsureBetAmount"
				align="center"
				label="保险投注金额"
			>
				<template slot-scope="scope">
					<FormItem :scope="scope" :updateData="updateData" />
				</template>
			</el-table-column>
			<el-table-column
				prop="dxInsureValidBetAmount"
				align="center"
				label="保险有效投注"
			>
				<template slot-scope="scope">
					<FormItem :scope="scope" :updateData="updateData" />
				</template>
			</el-table-column>
		</el-table>
		<!-- 德州俱乐部俱乐部服务费贡献  end-->

		<el-table
			v-loading="loading"
			element-loading-spinner="el-icon-loading"
			size="mini"
			border
			class="small-size-table"
			:data="formatVenueData(data)"
			style="width: 100%; margin: 15px 0"
			:header-cell-style="getRowClass"
			highlight-current-row
		>
			<el-table-column prop="userName" align="center">
				<template slot-scope="scope">
					{{ scope.row.label }}
				</template>
			</el-table-column>
			<el-table-column prop="NetAmount" align="center" label="游戏输赢">
				<template slot="header" slot-scope="{ column, $index }">
					<span>游戏输赢</span>
				</template>
				<template slot-scope="scope">
					<span v-if="scope.row.type === 'total'">
						{{ aomunt(scope.row.netAmountSub) }}
					</span>
					<FormItem v-else :scope="scope" :updateData="updateData" />
				</template>
			</el-table-column>
			<el-table-column
				prop="NetRecalculationAdjustmentAmount"
				align="center"
				label="输赢重算调整"
			>
				<template slot="header" slot-scope="{ column, $index }">
					<span>
						输赢重算调整
						<el-tooltip
							class="item"
							effect="dark"
							content="统计当期因注单重算而导致的输赢金额调整"
							placement="top-start"
						>
							<i class="el-icon-question"></i>
						</el-tooltip>
					</span>
				</template>
				<template slot-scope="scope">
					<span v-if="scope.row.type === 'total'">
						{{
							aomunt(
								scope.row.netRecalculationAdjustmentAmountSub
							)
						}}
					</span>
					<FormItem v-else :scope="scope" :updateData="updateData" />
				</template>
			</el-table-column>
			<el-table-column
				prop="RebateAmount"
				align="center"
				label="返水金额"
			>
				<template slot="header" slot-scope="{ column, $index }">
					<span>
						返水金额
						<el-tooltip
							class="item"
							effect="dark"
							content="统计当期获得的返水金额; 公式：有效投注*返水比例；公式仅作参考测算，测算结果不等同实际发放金额"
							placement="top-start"
						>
							<i class="el-icon-question"></i>
						</el-tooltip>
					</span>
				</template>
				<template slot-scope="scope">
					<span v-if="scope.row.type === 'total'">
						{{ aomunt(scope.row.rebateAmountSub) }}
					</span>
					<FormItem v-else :scope="scope" :updateData="updateData" />
				</template>
			</el-table-column>
			<el-table-column
				prop="RebateRecalculationAdjustmentAmount"
				align="center"
				label="返水重算调整"
			>
				<template slot="header" slot-scope="{ column, $index }">
					<span>
						返水重算调整
						<el-tooltip
							class="item"
							effect="dark"
							content="统计当期因注单重算而导致的返水金额调整"
							placement="top-start"
						>
							<i class="el-icon-question"></i>
						</el-tooltip>
					</span>
				</template>
				<template slot-scope="scope">
					<span v-if="scope.row.type === 'total'">
						{{
							aomunt(
								scope.row.rebateRecalculationAdjustmentAmountSub
							)
						}}
					</span>
					<FormItem v-else :scope="scope" :updateData="updateData" />
				</template>
			</el-table-column>
			<el-table-column
				prop="ActivityBonusAmount"
				align="center"
				label="其他收支项"
			>
				<template slot="header" slot-scope="{ column, $index }">
					<span>
						其他收支项
						<el-tooltip
							class="item"
							effect="dark"
							content="统计日期内会员的其他收支项，包含：真人打赏、电子活动奖金"
							placement="top-start"
						>
							<i class="el-icon-question"></i>
						</el-tooltip>
					</span>
				</template>
				<template slot-scope="scope">
					<span v-if="scope.row.type === 'total'">
						{{ aomunt(activityBonusAmountSub) }}
					</span>
					<template v-else>
						<FormItem
							:name="
								scope.row.type === 'zr'
									? 'zrRewardAmount'
									: 'dyActivityBonusAmount'
							"
							v-if="['zr', 'dy'].includes(scope.row.type)"
							:scope="scope"
							:updateData="updateData"
						/>
						<span v-else>/</span>
					</template>
				</template>
			</el-table-column>
			<el-table-column
				prop="MemberNetAmount"
				align="center"
				label="会员盈亏"
			>
				<template slot="header" slot-scope="{ column, $index }">
					<span>
						会员盈亏
						<el-tooltip
							class="item"
							effect="dark"
							placement="top-start"
						>
							<div slot="content">
								汇总其他场馆盈亏的总额公式：会员游戏输赢+输赢重算调整+返水金额+返水重算调整+其他收支
							</div>
							<i class="el-icon-question"></i>
						</el-tooltip>
					</span>
				</template>
				<template slot-scope="{ row }">
					<span v-if="row.type === 'total'">
						{{ aomunt(row.memberNetAmountSub) }}
					</span>
					<span v-else>
						{{ aomunt(row[`${row.type}MemberNetAmount`]) }}
					</span>
				</template>
			</el-table-column>
		</el-table>
		<el-table
			v-loading="loading"
			element-loading-spinner="el-icon-loading"
			size="mini"
			border
			class="small-size-table"
			:data="[data]"
			style="width: 100%; margin: 15px 0"
			:header-cell-style="getRowClass"
			highlight-current-row
		>
			<el-table-column prop="tyValidBetAmount" align="center">
				<template slot-scope="scope">有效投注</template>
			</el-table-column>
			<el-table-column
				prop="tyValidBetAmount"
				align="center"
				label="体育"
			>
				<template slot-scope="scope">
					<FormItem :scope="scope" :updateData="updateData" />
				</template>
			</el-table-column>
			<el-table-column
				prop="djValidBetAmount"
				align="center"
				label="电竞"
			>
				<template slot-scope="scope">
					<FormItem :scope="scope" :updateData="updateData" />
				</template>
			</el-table-column>
			<el-table-column
				prop="qpValidBetAmount"
				align="center"
				label="棋牌"
			>
				<template slot-scope="scope">
					<FormItem :scope="scope" :updateData="updateData" />
				</template>
			</el-table-column>
			<el-table-column
				prop="cpValidBetAmount"
				align="center"
				label="彩票"
			>
				<template slot-scope="scope">
					<FormItem :scope="scope" :updateData="updateData" />
				</template>
			</el-table-column>
			<el-table-column
				prop="dyValidBetAmount"
				align="center"
				label="电子"
			>
				<template slot-scope="scope">
					<FormItem :scope="scope" :updateData="updateData" />
				</template>
			</el-table-column>
			<el-table-column
				prop="zrValidBetAmount"
				align="center"
				label="真人"
			>
				<template slot-scope="scope">
					<FormItem :scope="scope" :updateData="updateData" />
				</template>
			</el-table-column>
		</el-table>
		<el-table
			v-loading="loading"
			element-loading-spinner="el-icon-loading"
			size="mini"
			class="small-size-table"
			:data="[data]"
			border
			style="width: 100%; margin: 15px 0"
			:header-cell-style="getRowClass"
			highlight-current-row
		>
			<el-table-column align="center">
				<template slot-scope="scope">其他</template>
			</el-table-column>
			<el-table-column
				prop="rebateAdjustmentAmount"
				align="center"
				label="返水调整"
			>
				<template slot="header" slot-scope="{ column, $index }">
					<span>返水调整</span>
				</template>
				<template slot-scope="scope">
					<FormItem :scope="scope" :updateData="updateData" />
				</template>
			</el-table-column>
			<el-table-column
				prop="accountAdjustmentAmount"
				align="center"
				label="账户调整"
			>
				<template slot="header" slot-scope="{ column, $index }">
					<span>账户调整</span>
				</template>
				<template slot-scope="scope">
					<FormItem :scope="scope" :updateData="updateData" />
				</template>
			</el-table-column>
			<el-table-column
				prop="otherTotalNetAmount"
				align="center"
				label="其他盈亏总计"
			>
				<template slot="header" slot-scope="{ column, $index }">
					<span>
						其他盈亏总计
						<el-tooltip
							class="item"
							effect="dark"
							placement="top-start"
						>
							<div slot="content">
								汇总其他项盈亏的总额;
								<br />
								公式：账户调整+返水调整
							</div>
							<i class="el-icon-question"></i>
						</el-tooltip>
					</span>
				</template>
				<template slot-scope="scope">
					<span>
						{{ aomunt(otherNetAmount) }}
					</span>
				</template>
			</el-table-column>
		</el-table>
	</div>
</template>

<script>
import FormItem from './formItem.vue'
import mixin from './mixin.js'
import list from '@/mixins/list'
export default {
  components: {
    FormItem
  },
  mixins: [list, mixin],
  props: {
    data: {
      type: Object,
      default: {}
    },
    netAmount: {
      type: Number | String,
      default: ''
    }
  },
  data() {
    return {
    }
  },
  computed: {
    // 汇总德州场馆盈亏的总额; 公式：俱乐部游戏输赢+鱿鱼游戏输赢+局服务费+保险投注输赢+增值服务消费+返水金额
    dxClubMemberNetAmount() {
      const {
        dxClubNetAmount,
        dxSquidNetAmount,
        serviceChargeRoundAmount,
        dxInsureNetAmount,
        valueAddedTotalAmount,
        rebateAmount
      } = this.data

      if (!this.checkNums([
        dxClubNetAmount,
        dxSquidNetAmount,
        serviceChargeRoundAmount,
        dxInsureNetAmount,
        valueAddedTotalAmount,
        rebateAmount
      ])) return '/'

      return (
        dxClubNetAmount +
        dxSquidNetAmount +
        serviceChargeRoundAmount +
        dxInsureNetAmount +
        valueAddedTotalAmount +
        rebateAmount
      )
    },

    // 公式：会员游戏输赢+输赢重算调整+返水金额+返水重算调整+其他收支
    tyMemberNetAmount() {
      const { tyNetAmount, tyRebateAmount, tyRebateRecalculationAdjustmentAmount, tyNetRecalculationAdjustmentAmount } = this.data
      return this.calculateTotal([
        tyNetAmount,
        tyRebateAmount,
        tyRebateRecalculationAdjustmentAmount,
        tyNetRecalculationAdjustmentAmount
      ])
    },

    djMemberNetAmount() {
      const { djNetAmount, djRebateAmount, djNetRecalculationAdjustmentAmount, djRebateRecalculationAdjustmentAmount } = this.data
      return this.calculateTotal([
        djNetAmount,
        djRebateAmount,
        djNetRecalculationAdjustmentAmount,
        djRebateRecalculationAdjustmentAmount
      ])
    },

    qpMemberNetAmount() {
      const { qpNetAmount, qpRebateAmount, qpNetRecalculationAdjustmentAmount, qpRebateRecalculationAdjustmentAmount } = this.data
      return this.calculateTotal([
        qpNetAmount,
        qpRebateAmount,
        qpNetRecalculationAdjustmentAmount,
        qpRebateRecalculationAdjustmentAmount
      ])
    },

    cpMemberNetAmount() {
      const { cpNetAmount, cpRebateAmount, cpNetRecalculationAdjustmentAmount, cpRebateRecalculationAdjustmentAmount } = this.data
      return this.calculateTotal([
        cpNetAmount,
        cpRebateAmount,
        cpNetRecalculationAdjustmentAmount,
        cpRebateRecalculationAdjustmentAmount
      ])
    },

    dyMemberNetAmount() {
      const { dyNetAmount, dyRebateAmount, dyNetRecalculationAdjustmentAmount, dyRebateRecalculationAdjustmentAmount, dyActivityBonusAmount } = this.data
      return this.calculateTotal([
        dyNetAmount,
        dyRebateAmount,
        dyNetRecalculationAdjustmentAmount,
        dyRebateRecalculationAdjustmentAmount,
        dyActivityBonusAmount
      ])
    },

    zrMemberNetAmount() {
      const { zrNetAmount, zrRebateAmount, zrNetRecalculationAdjustmentAmount, zrRebateRecalculationAdjustmentAmount, zrRewardAmount } = this.data
      return this.calculateTotal([
        zrNetAmount,
        zrRebateAmount,
        zrNetRecalculationAdjustmentAmount,
        zrRebateRecalculationAdjustmentAmount,
        zrRewardAmount
      ])
    },

    netAmountSub() {
      const { tyNetAmount, djNetAmount, qpNetAmount, cpNetAmount, dyNetAmount, zrNetAmount } = this.data
      return this.calculateTotal([
        tyNetAmount,
        djNetAmount,
        qpNetAmount,
        cpNetAmount,
        dyNetAmount,
        zrNetAmount
      ])
    },
    netRecalculationAdjustmentAmountSub() {
      const {
        tyNetRecalculationAdjustmentAmount,
        djNetRecalculationAdjustmentAmount,
        qpNetRecalculationAdjustmentAmount,
        cpNetRecalculationAdjustmentAmount,
        dyNetRecalculationAdjustmentAmount,
        zrNetRecalculationAdjustmentAmount
      } = this.data
      return this.calculateTotal([
        tyNetRecalculationAdjustmentAmount,
        djNetRecalculationAdjustmentAmount,
        qpNetRecalculationAdjustmentAmount,
        cpNetRecalculationAdjustmentAmount,
        dyNetRecalculationAdjustmentAmount,
        zrNetRecalculationAdjustmentAmount
      ])
    },
    rebateAmountSub() {
      const {
        tyRebateAmount,
        djRebateAmount,
        qpRebateAmount,
        cpRebateAmount,
        dyRebateAmount,
        zrRebateAmount
      } = this.data
      return this.calculateTotal([
        tyRebateAmount,
        djRebateAmount,
        qpRebateAmount,
        cpRebateAmount,
        dyRebateAmount,
        zrRebateAmount
      ])
    },
    rebateRecalculationAdjustmentAmountSub() {
      const {
        tyRebateRecalculationAdjustmentAmount,
        djRebateRecalculationAdjustmentAmount,
        qpRebateRecalculationAdjustmentAmount,
        cpRebateRecalculationAdjustmentAmount,
        dyRebateRecalculationAdjustmentAmount,
        zrRebateRecalculationAdjustmentAmount
      } = this.data
      return this.calculateTotal([
        tyRebateRecalculationAdjustmentAmount,
        djRebateRecalculationAdjustmentAmount,
        qpRebateRecalculationAdjustmentAmount,
        cpRebateRecalculationAdjustmentAmount,
        dyRebateRecalculationAdjustmentAmount,
        zrRebateRecalculationAdjustmentAmount
      ])
    },
    // 其他收支
    activityBonusAmountSub() {
      const {
        dyActivityBonusAmount,
        zrRewardAmount
      } = this.data
      return this.calculateTotal([
        dyActivityBonusAmount,
        zrRewardAmount
      ])
    },

    memberNetAmountSub() {
      return this.calculateTotal([
        this.tyMemberNetAmount,
        this.djMemberNetAmount,
        this.qpMemberNetAmount,
        this.cpMemberNetAmount,
        this.dyMemberNetAmount,
        this.zrMemberNetAmount
      ])
    },
    // 其他盈亏总计
    // 汇总其他项盈亏的总额; 公式：账户调整+返水调整
    otherNetAmount() {
      const { rebateAdjustmentAmount,
        accountAdjustmentAmount
      } = this.data
      return this.calculateTotal([
        rebateAdjustmentAmount,
        accountAdjustmentAmount
      ])
    }
  },
  watch: {
    tyMemberNetAmount(val, old) {
      this.updateData(val, 'tyMemberNetAmount')
    },
    djMemberNetAmount(val, old) {
      this.updateData(val, 'djMemberNetAmount')
    },
    djNetRecalculationAdjustmentAmount(val, old) {
      this.updateData(val, 'djNetRecalculationAdjustmentAmount')
    },
    qpMemberNetAmount(val, old) {
      this.updateData(val, 'qpMemberNetAmount')
    },
    cpMemberNetAmount(val, old) {
      this.updateData(val, 'cpMemberNetAmount')
    },
    dyMemberNetAmount(val, old) {
      this.updateData(val, 'dyMemberNetAmount')
    },
    zrMemberNetAmount(val, old) {
      this.updateData(val, 'zrMemberNetAmount')
    },
    netAmountSub(val) {
      this.updateData(val, 'netAmountSub')
    },
    rebateAmountSub(val) {
      this.updateData(val, 'rebateAmountSub')
    },
    rebateRecalculationAdjustmentAmountSub(val) {
      this.updateData(val, 'rebateRecalculationAdjustmentAmountSub')
    },
    netRecalculationAdjustmentAmountSub(val) {
      this.updateData(val, 'netRecalculationAdjustmentAmountSub')
    },
    memberNetAmountSun(val) {
      this.updateData(val, 'memberNetAmountSun')
    },
    otherNetAmount(val) {
      this.updateData(val, 'otherNetAmount')
    },
    memberNetAmountSub(val) {
      this.updateData(val, 'memberNetAmountSub')
    }
  },

  mounted() {
    this.$emit('update:data', {
      ...this.data,
      ...{
        tyMemberNetAmount: this.tyMemberNetAmount,
        djMemberNetAmount: this.djMemberNetAmount,
        qpMemberNetAmount: this.qpMemberNetAmount,
        cpMemberNetAmount: this.cpMemberNetAmount,
        dyMemberNetAmount: this.dyMemberNetAmount,
        zrMemberNetAmount: this.zrMemberNetAmount,

        netAmountSub: this.netAmountSub,
        netRecalculationAdjustmentAmountSub: this.netRecalculationAdjustmentAmountSub,
        rebateAmountSub: this.rebateAmountSub,
        rebateRecalculationAdjustmentAmountSub: this.rebateRecalculationAdjustmentAmountSub,
        memberNetAmountSub: this.memberNetAmountSub,

        otherNetAmount: this.otherNetAmount
      }
    })
  }
}
</script>
<style scoped>
.bill-title{
    text-align: center;
}
.contentBox {
	text-align: center;
	font-size: 18px;
	font-weight: bold;
}
</style>

